<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>source_pdf</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="LIBIT Documentation"
HREF="index.html"><LINK
REL="UP"
HREF="refmanual.html"><LINK
REL="PREVIOUS"
TITLE="source_binary"
HREF="man.source-binary.html"><LINK
REL="NEXT"
TITLE="source_uniform"
HREF="man.source-uniform.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>LIBIT Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="man.source-binary.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="man.source-uniform.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="MAN.SOURCE-PDF"
></A
>source_pdf</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN11275"
></A
><H2
>Name</H2
>source_pdf&nbsp;--&nbsp;generic continuous source generator</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN11278"
></A
><H2
>Synopsis</H2
><DIV
CLASS="FUNCSYNOPSIS"
><P
></P
><A
NAME="AEN11279"
></A
><PRE
CLASS="FUNCSYNOPSISINFO"
>#include &lt;it/source.h&gt;
      </PRE
><P
><CODE
><CODE
CLASS="FUNCDEF"
>vec source_pdf</CODE
>( size_t size, double a, double b, it_function_t pdf, it_args_t args
        );</CODE
></P
><P
></P
></DIV
></DIV
><H2
>DESCRIPTION</H2
><P
> This function generates a random continuous vector of length <CODE
CLASS="PARAMETER"
>size</CODE
> where each sample is drawn from the distribution <CODE
CLASS="PARAMETER"
>pdf</CODE
>. This distribution is assumed to be null outside the range [<CODE
CLASS="PARAMETER"
>a</CODE
>, <CODE
CLASS="PARAMETER"
>b</CODE
>] and to attain its maximal value in 0. Specific parameters for the distribution function are passed through the <CODE
CLASS="PARAMETER"
>args</CODE
> argument.  </P
><H2
>RETURN VALUE</H2
><P
>    
   </P
><H2
>EXAMPLE</H2
><PRE
CLASS="PROGRAMLISTING"
>&#13;#include &lt;source.h&gt;

...

/* parameters of the Laplacian distribution */
it_function_args(laplacian_pdf) {
  double lambda;
};
/* Laplacian probability density function definition (symmetric) */
it_function(laplacian_pdf)
{
  double lambda = it_this-&#38;gt;lambda;
  return(1. / (2.*lambda) * exp(-fabs(x) / lambda));
}
/*-- generate a random number according to this p.d.f. --*/
/* declare the Laplacian parameters */
it_function_args(laplacian_pdf) laplacian_args;
/* set the Laplacian parameter lambda to 1/sqrt(2) (variance equal to 1) */
laplacian_args.lambda = 1/sqrt(2.0);
/* generate laplacian source of 20 samples, assuming the distribution is */
/* null outside the range [-10,10]                                       */
double s = source_pdf(10, -10, 10, laplacian_pdf, &#38;#38;laplacian_args);</PRE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="man.source-binary.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="man.source-uniform.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>source_binary</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="refmanual.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>source_uniform</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>